Graphing all the environmental data together. The data sets here have had the outliers removed and are hourly medians (code here: https://cmwegener.github.io/thesis/environmental_data.html). Final graph still needs some aesthetics work
Set up
rm(list=ls())
library(tidyverse)
library(ggpubr)
library(scales)
library(chron)
library(plotly)
library(taRifx)
library(aweek)
library(easypackages)
library(renv)
library(here)
library(ggthemes)
library(gridExtra)
library(patchwork)
library(tidyquant)
library(recipes)
library(cranlogs)
library(knitr)
library(openair)
library(extrafont)
For downloading and importings more fonts to R. Takes a few minutes to download but you only have to do the first time. Font styles here: http://www.cookbook-r.com/Graphs/Fonts/. Pasting it as text here so the code doesn’t run every time
install.packages(“extrafont”) library(extrafont) font_import() loadfonts(device=“win”)
checks which fonts you have fonts()
Salinity
cc.sal<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/cc_sal.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
eos.sal<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/eos_sal.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
rb.sal<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/rb_sal.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
fp.sal<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/fp_sal.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
cc.sal$date<-as.Date(cc.sal$date, format = c("%Y-%m-%d"))
eos.sal$date<-as.Date(eos.sal$date, format = c("%Y-%m-%d"))
rb.sal$date<-as.Date(rb.sal$date, format = c("%Y-%m-%d"))
fp.sal$date<-as.Date(fp.sal$date, format = c("%Y-%m-%d"))
cc.sal.g<-
cc.sal%>%
ggplot(aes(x=date, y=salinity))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_hline(yintercept=10, linetype="dashed", color = "red")+
geom_point(aes(color=salinity),alpha=0.5)+
ylim(0,35)+
scale_color_gradient(limits=c(0,35), low="skyblue", high="skyblue4")+
labs(col="Salinity",
title="China Camp",
subtitle="data courtesy of NERR",
x=(""),y=("Salinity (ppt)"))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
eos.sal.g<-
eos.sal%>%
ggplot(aes(x=date, y=salinity))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_hline(yintercept=10, linetype="dashed", color = "red")+
geom_point(aes(color=salinity),alpha=0.5)+
ylim(0,35)+
scale_color_gradient(limits=c(0,35), low="skyblue", high="skyblue4")+
labs(col="Salinity",
title="EOS in Tiburon",
subtitle="data courtesy of CeNCOOS",
x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
rb.sal.g<-
rb.sal%>%
ggplot(aes(x=date, y=salinity))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-15"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_hline(yintercept=10, linetype="dashed", color = "red")+
geom_point(aes(color=salinity),alpha=0.5)+
ylim(0,35)+
scale_color_gradient(limits=c(0,35), low="skyblue", high="skyblue4")+
labs(col="Salinity",
title="Richardson Bay",
subtitle="data courtesy of NERR",
x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
fp.sal.g<-
fp.sal%>%
ggplot(aes(x=date, y=salinity))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_hline(yintercept=10, linetype="dashed", color = "red")+
geom_point(aes(color=salinity),alpha=0.5)+
ylim(0,35)+
scale_color_gradient(limits=c(0,35), low="skyblue", high="skyblue4", name= "Salinity (ppt)")+
labs(col="Salinity",
title="Fort Point",
subtitle="data courtesy of CeNCOOS",
x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
sal.all<-ggarrange(cc.sal.g, eos.sal.g, rb.sal.g, fp.sal.g, ncol=4, nrow=1, common.legend = TRUE, legend="top")
## Warning: Removed 2898 rows containing missing values (geom_point).
## Warning: Removed 2898 rows containing missing values (geom_point).
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font metrics
## unknown for character 0x4d
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x67
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x6a
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x70
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x71
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x79
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x51
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font metrics
## unknown for character 0x4d
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x67
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x6a
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x70
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x71
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x79
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font width
## unknown for character 0x51
## Warning: Removed 2490 rows containing missing values (geom_point).
## Warning: Removed 3681 rows containing missing values (geom_point).
## Warning: Removed 5283 rows containing missing values (geom_point).
sal.all
pH
cc.ph<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/cc_ph.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
eos.ph<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/eos_ph.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
rb.ph<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/rb_ph.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
#no fort point ph data
cc.ph$date<-as.Date(cc.ph$date, format = c("%Y-%m-%d"))
eos.ph$date<-as.Date(eos.ph$date, format = c("%Y-%m-%d"))
rb.ph$date<-as.Date(rb.ph$date, format = c("%Y-%m-%d"))
cc.ph.g<-
cc.ph%>%
ggplot(aes(x=date, y=ph))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=ph),alpha=0.5)+
ylim(6.5, 9)+
scale_color_gradient(limits=c(6.5, 9), low="skyblue", high="skyblue4")+
labs(col="pH", x=(""),y=("pH"))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
eos.ph.g<-
eos.ph%>%
ggplot(aes(x=date, y=ph))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=ph),alpha=0.5)+
ylim(6.5, 9)+
scale_color_gradient(limits=c(6.5, 9), low="skyblue", high="skyblue4")+
labs( col="pH", x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
rb.ph.g<-
rb.ph%>%
ggplot(aes(x=date, y=ph))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-15"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=ph),alpha=0.5)+
ylim(6.5, 9)+
scale_color_gradient(limits=c(6.5, 9), low="skyblue", high="skyblue4")+
labs(col="pH", x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
#creating a blank plot since there is no data
fp.ph.g<-
rb.ph%>%
ggplot(aes(x=date, y=ph))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-15"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
annotate("text", x = as.Date("2017-06-01"), y=9, label = "No Data", size=8)+
geom_point(aes(color=ph),alpha=0)+
ylim(6.5, 9)+
scale_color_gradient(limits=c(6.5, 9), low="skyblue", high="skyblue4", name= "pH")+
labs(col="pH", x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black"),
)
ph.all<-ggarrange(cc.ph.g, eos.ph.g, rb.ph.g, fp.ph.g, ncol=4, nrow=1, common.legend = TRUE, legend="top")
## Warning: Removed 11268 rows containing missing values (geom_point).
## Warning: Removed 11268 rows containing missing values (geom_point).
## Warning: Removed 1025 rows containing missing values (geom_point).
## Warning: Removed 9013 rows containing missing values (geom_point).
## Warning: Removed 9013 rows containing missing values (geom_point).
ph.all
Dissolved Oxygen
cc.do<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/cc_do.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
eos.do<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/eos_do.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
rb.do<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/rb_do.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
#no fort point do data
cc.do$date<-as.Date(cc.do$date, format = c("%Y-%m-%d"))
eos.do$date<-as.Date(eos.do$date, format = c("%Y-%m-%d"))
rb.do$date<-as.Date(rb.do$date, format = c("%Y-%m-%d"))
cc.do.g<-
cc.do%>%
ggplot(aes(x=date, y=do))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=do),alpha=0.5)+
ylim(0, 22)+
scale_color_gradient(limits=c(0, 22), low="skyblue", high="skyblue4")+
labs(col="Dissolved Oxygen", x=(""),y=("Dissolved Oxygen"))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
eos.do.g<-
eos.do%>%
ggplot(aes(x=date, y=do))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=do),alpha=0.5)+
ylim(0, 22)+
scale_color_gradient(limits=c(0, 22), low="skyblue", high="skyblue4")+
labs(col="Dissolved Oxygen", x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
rb.do.g<-
rb.do%>%
ggplot(aes(x=date, y=do))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-15"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=do),alpha=0.5)+
ylim(0, 22)+
scale_color_gradient(limits=c(0, 22), low="skyblue", high="skyblue4", name= "Dissolved Oxygen")+
labs(col="Dissolved Oxygen",x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
#creating a blank plot since there is no data
fp.do.g<-
rb.do%>%
ggplot(aes(x=date, y=do))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-15"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
annotate("text", x = as.Date("2017-06-01"), y=20, label = "No Data", size=8)+
geom_point(aes(color=do),alpha=0)+
ylim(0, 22)+
scale_color_gradient(limits=c(0, 22), low="skyblue", high="skyblue4", name="Dissolved Oxygen")+
labs(col="Dissolved Oxygen",x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black"),
)
do.all<-ggarrange(cc.do.g, eos.do.g, rb.do.g, fp.do.g, ncol=4, nrow=1, common.legend = TRUE, legend="top")
## Warning: Removed 1461 rows containing missing values (geom_point).
## Warning: Removed 1461 rows containing missing values (geom_point).
## Warning: Removed 1203 rows containing missing values (geom_point).
## Warning: Removed 2103 rows containing missing values (geom_point).
## Warning: Removed 2103 rows containing missing values (geom_point).
do.all
Water temperature
cc.watertemp<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/cc_watertemp.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
eos.watertemp<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/eos_watertemp.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
rb.watertemp<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/rb_watertemp.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
fp.watertemp<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/fp_watertemp.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
cc.watertemp$date<-as.Date(cc.watertemp$date, format = c("%Y-%m-%d"))
eos.watertemp$date<-as.Date(eos.watertemp$date, format = c("%Y-%m-%d"))
rb.watertemp$date<-as.Date(rb.watertemp$date, format = c("%Y-%m-%d"))
fp.watertemp$date<-as.Date(fp.watertemp$date, format = c("%Y-%m-%d"))
cc.watertemp.g<-
cc.watertemp%>%
ggplot(aes(x=date, y=water_temp))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=water_temp),alpha=0.5)+
ylim(5,33)+
scale_color_gradient(limits=c(5,33), low="skyblue", high="skyblue4")+
labs(col="Water Temperature (C)",x=(""),y=("Water Temperature (C)"))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
eos.watertemp.g<-
eos.watertemp%>%
ggplot(aes(x=date, y=water_temp))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=water_temp),alpha=0.5)+
ylim(5,33)+
scale_color_gradient(limits=c(5,33), low="skyblue", high="skyblue4")+
labs(col="Water Temperature (C)",x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
rb.watertemp.g<-
rb.watertemp%>%
ggplot(aes(x=date, y=water_temp))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-15"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=water_temp),alpha=0.5)+
ylim(5,33)+
scale_color_gradient(limits=c(5,33), low="skyblue", high="skyblue4", name= "Water Temperature (C)")+
labs(col="Water Temperature (C)",x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")
)
fp.watertemp.g<-
fp.watertemp%>%
ggplot(aes(x=date, y=water_temp))+
annotate("rect", fill = "grey", alpha = 0.5,
xmin = as.Date("2018-06-14"), xmax = as.Date("2019-09-12"),
ymin = -Inf, ymax = Inf) +
geom_point(aes(color=water_temp),alpha=0.5)+
ylim(5,33)+
scale_color_gradient(limits=c(5,33), low="skyblue", high="skyblue4", name="Water Temperature (C)")+
labs(col="Water Temperature (C)",x=(""),y=(""))+
theme(axis.text.x=element_text(family="Calibri Light", color="black", size =20,
angle =0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y=element_text(family="Calibri Light", color= "black", size =20,
angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x= element_text(family="Calibri Light", color="black", size=20,
angle =0, hjust =.5, vjust = 0, face = "plain"),
axis.title.y=element_text(family="Calibri Light", color="black", size= 20,
angle =90, hjust =.5, vjust =.5, face = "plain"),
title = element_text (family="Calibri Light",color = "black", size = 20,
angle = 0, hjust = .5, vjust = .5, face = "plain"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black"),
)
watertemp.all<-ggarrange(cc.watertemp.g, eos.watertemp.g, rb.watertemp.g, fp.watertemp.g, ncol=4, nrow=1, common.legend = TRUE, legend="top")
## Warning: Removed 2798 rows containing missing values (geom_point).
## Warning: Removed 2798 rows containing missing values (geom_point).
## Warning: Removed 2203 rows containing missing values (geom_point).
## Warning: Removed 3494 rows containing missing values (geom_point).
## Warning: Removed 5037 rows containing missing values (geom_point).
watertemp.all
All together Need to find a bettter way to do a title and subtitle. This works for now
all<-ggarrange(sal.all, ph.all, do.all, watertemp.all, nrow=4, ncol=1)
all+plot_annotation(title='Hourly median environmental data',
subtitle='01/01/2017 - 12/31/2019',
theme = theme(plot.title = element_text(size = 30, family="Calibri Light"),
plot.subtitle = element_text(size=20, family="Calibri Light")))
-Fonts still too small
-Need to add units -Don’t love ledgend position -Legend values too small -Label shaded region as field survey dates or add to figure decription?
-Should I add x-axis breaks every 6 months?
-Different color for each row/variable?